OBJS = *.o
GCC = g++
CFLAGS = -fPIC -g -c
DSOFLAGS = --shared --export-dynamic -Wl,-soname,
SRC = Question.cpp QuestionFactory.cpp MathQuestion.cpp TextQuestion.cpp Security.h RandomNumbers.cpp RandomNumbers.h

pam_quiz.o: $(SRC) main.cpp
	$(GCC) -c -g $?

pam_quiz_c.o: pam_quiz.c
	$(GCC) $(CFLAGS) $?
	
pam_quizc.so: pam_quiz_c.o
	$(GCC) $(DSOFLAGS)pam_quizc -o pam_quizc.so pam_quiz_c.o -lpam;sudo cp pam_quizc.so /lib/security

pam_quiz_mod.o: $(SRC) pam_quiz.cpp
	$(GCC) $(CFLAGS) $?

pam_quiz_test.o: $(SRC) main.cpp
	$(GCC) $(CFLAGS) $?
		
pam_quiz: pam_quiz.o
	$(GCC) -o $@ $(OBJS)
	
pam_quiz_mod: pam_quiz_mod.o
	$(GCC) $(DSOFLAGS)pam_quiz -o pam_quiz.so $(OBJS) -lpam; sudo cp pam_quiz.so /lib/security/

pam_quiz_test: pam_quiz_test.o
	$(GCC) $(DSOFLAGS)pam_quiz_test -o pam_quiz_test.so $(OBJS) -lpam
		
install: pam_quiz clean_obj
install_mod: pam_quiz_mod clean_obj
install_mod_test: pam_quiz_test clean_obj
install_c: pam_quizc.so clean_obj

clean_obj:
	rm -f *.o;

clean: clean_obj
	rm -f pam_quiz
